package com.example.newsSys.dao;

import com.example.newsSys.domain.News;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface NewsDao {
    List<News> getNews(@Param("newsPaperName") String newsPaperName, @Param("fileTitle") String fileTitle, @Param("start") Integer start, @Param("pageSize") Integer pageSize);

    @Insert("insert into news(newsDate, newsName, layoutName, newsAuthor, newsTitle, newsInfo, newsContent) " +
            "VALUES" +
            "(#{newsDate},#{newsName},#{layoutName},#{newsAuthor},#{newsTitle},#{newsInfo},#{newsContent})")
    int add(News news);
    @Select("select * from news where id = #{id}")
    News getNewsById(int id);

    int update(News news);
    @Delete("delete from news where id = #{id}")
    int delete(int id);

    Integer getTotal(@Param("newsPaperName") String newsPaperName, @Param("fileTitle") String fileTitle);
}
